<template>
  <a-card :bordered="false">
    <!-- <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :sm="24">
            <a-form-item label="开始日期">
              <a-input placeholder="请选择开始日期" />
            </a-form-item>
          </a-col>
          <a-col :sm="24">
            <a-form-item label="结束日期">
              <a-input v-model="queryParam.id"
                       placeholder="请选择结束日期" />
            </a-form-item>
          </a-col>
          <a-col :sm="24">
            <span class="table-page-search-submitButtons"
                  :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
              <a-button type="primary">查询</a-button>
              <a-button style="margin-left: 8px"
                        @click="resetSearchForm">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div> -->

    <s-table ref="table"
             size="default"
             :columns="columns"
             :data="loadData"
             :showAlertInfo="true"
             @onSelect="onChange">
    </s-table>

  </a-card>
</template>

<script>
import STable from '@/components/table/'
import ATextarea from "ant-design-vue/es/input/TextArea"
import AInput from "ant-design-vue/es/input/Input"
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import moment from "moment"
import axios from 'axios';
import { getRoleList, getServiceList } from '@/api/manage'

export default {
  name: "TableList",
  components: {
    AInput,
    ATextarea,
    STable
  },
  data () {
    return {
      url: {
        list: "/device/deviceInfo/warehouseReport",
      },
      visibleCreateModal: false,
      visible: false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      form: null,
      mdl: {},

      // // 高级搜索 展开/关闭
      advanced: true,
      // 查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: '公司名称',
          dataIndex: 'buyDepart_dictText'
        },
        {
          title: '当前库存数量',
          dataIndex: 'inWarehouse'
        },
        {
          title: '出库数量',
          dataIndex: 'outWarehouse',
        },
        {
          title: '入库数量',
          dataIndex: 'sumWarehouse',
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        return getServiceList(this.url.list, Object.assign(parameter, this.queryParam))
          .then(res => {
            res.result.data = res.result.records
            return res.result
          })
      },

      selectedRowKeys: [],
      selectedRows: []
    }
  },
  created () {
  },
  methods: {
    handleEdit (record) {
      this.mdl = Object.assign({}, record)
      console.log(this.mdl)
      this.visible = true
    },
    handleOk () {

    },

    onChange (row) {
      this.selectedRowKeys = row.selectedRowKeys
      this.selectedRows = row.selectedRows

      console.log(this.$refs.table)
    },
    toggleAdvanced () {
      this.advanced = !this.advanced
    },

    resetSearchForm () {
      this.queryParam = {
        date: moment(new Date())
      }
    }
  },
  watch: {
    /*
    'selectedRows': function (selectedRows) {
      this.needTotalList = this.needTotalList.map(item => {
        return {
          ...item,
          total: selectedRows.reduce( (sum, val) => {
            return sum + val[item.dataIndex]
          }, 0)
        }
      })
    }
    */
  }
}
</script>